Repository navigation
fix(studio): an undo or redo that adds a sealed page's first edit stays in place - #8462
Merged
Merged
Conversation
…ys in place A sealed preview only got its seek-reapply script when its file already held a Studio edit, and the script left a page with none unarmed. The first restore that added one (a redo of a resize, say) was refused by the frame and fell back to an unawaited reload. Every sealed page now carries the script, armed from the start.
Contributor
Edit accuracy: accurate 271 (base branch 271), smooth 71 of thoseThe gate passes. Quarantined, measured but not gated (0) |
jrusso1020
approved these changes
Nov 22, 2026
jrusso1020
left a comment
Collaborator
There was a problem hiding this comment.
Approve. I reviewed at 48feecd0.
Need ✅ · Size ✅ (+65 −9) · Reuse ✅ · Simpler ✅ · Structure ✅
Risk: low. Only HTML served under preview/~<token>/ gets the script, and only Studio's sealed frames load that. The render and unsealed script keeps its early return.
What I checked:
withSeekReapplyArmedForAnyEditstill runs only on 200text/htmlresponses. A plain (non-iframe) load still gets no script.- The sealed wrapper returns at once in a top-level or same-origin window.
htmlHasStudioPositionEditsis still used by the producer (htmlCompiler.ts:2743), so dropping its import here leaves nothing dead.- The per-frame cost on a page with no edit is measured in the body: 0.032 ms with the playhead moving, sealed only.
- The two touched suites pass, 93/93, and
tsc --noEmiton studio-server is clean. - fails without the fix: confirmed. With both helpers as on main, 5 tests fail: the four "keeps a … mark a restore adds to a sealed page that loaded with none" rows, plus the sealed-document test in
preview.opaqueFrameLoads.test.ts.
— Rames (hf-review)
This was referenced Nov 22, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
In a sealed Studio preview, an undo or redo that adds an element's first Studio edit now stays on screen. Before, the redo of a resize saved the right file, but the preview kept showing the undone size until a reload landed.
Why
A sealed preview keeps Studio's size, rotation, path and motion edits applied through its seek-reapply script. That script was added to a sealed page only when its file already held one of those edits, and it did nothing on a page with none. So a redo that put back a page's first box size reached a frame with no script running. The frame refused it (
restore-attributesneeds a started reapply), and Studio fell back to a full reload that nothing waited for.On main, with the sealed preview on, a logged edit-accuracy run of
resize-none-px-r0-root-z100showed the redo's restore admitted (revision 3 over 2) and the frame answeringapplied: false, every time. Whether the bench then sees the box wrong depends on whether the fallback reload lands before it measures: the redo box was 60 px off in 5 of 9 runs on main: 4 of 4 at two parallel jobs, 1 of 2 at one job, 0 of 3 at one job with screenshots on. The unsealed preview never hits this: Studio installs its own reapply in a frame it can reach.Related work
Refs #7846 (Studio's preview sealed by default). Its edit-accuracy gate has a sealed-only undo row this clears for resize.
How
opaqueFrameLoads.ts: every sealed page carries the seek-reapply script, whether or not its file has a Studio edit yet. Studio can't add it once a sealed page has loaded.manualEditsRenderScript.ts: in a sealed frame (followFrames), the script stays armed on a page with no edit and reapplies whatever marks exist at each seek. The render and unsealed script (createStudioPositionSeekReapplyScript) keeps its early return, so renders don't change.opaqueFrameLoadsrewrites only HTML served underpreview/~<token>/, which only Studio's sealed frames load. The producer adds its own copy (htmlCompiler.ts), and the sealed script returns at once in a top-level window.reapplyPositionEditsAfterSeek,installManualEditReapply) is deleted. It stays out of this PR because Studio calls that copy synchronously at selection, DOM-edit sync and load, not only on seeks, so moving it changes the unsealed preview's timing.Test plan
fails without the fix:
manualEditsRenderScript.test.ts"keeps a %s mark a restore adds to a sealed page that loaded with none": one row each for box-size, rotation, path-offset and motion. A sealed page loads with no edit, a restore adds the mark, and the next frame puts it back.preview.opaqueFrameLoads.test.ts"puts Studio's seek reapply last in every sealed document, edited or not, and in no plain one".Both files pass three runs in a row on Linux (93 tests). Pre-commit passes: lint, format, fallow, typecheck.
Edit-accuracy bench, sealed preview on (
VITE_STUDIO_OPAQUE_PREVIEW_ENABLED=true), 8 resize cases (none, spin, hold, scale, fromto, seqresize), 3 runs: the undo check (undo and redo bytes identical, box within 0.5 px) passes in all 24, redo box 0 px. On main the same redo is refused every run (see Why). Other metrics in these cases are outside this change.Cost on a page with no Studio edit (500 elements, Chrome 158 headless, median of 5):
Not exercised: a full gate run of #7846 with this merged; the other sealed undo rows (lost undos in held and fast key sequences) have their own root.